package chinaums.web.controller;

import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import chinaums.common.util.FTPUtil;
import chinaums.entity.InsertInfo;
import chinaums.entity.ResultInsertInfo;
import chinaums.service.InsertInfoService;

import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.TypeReference;
import com.fasterxml.jackson.core.JsonParseException;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;

/**
 * @author ysq
 */
@Controller
@RequestMapping("/v2")
public class ReadFtpController {

	@Resource(name = "insertInfoService")
	private InsertInfoService insertInfoService;

	/**
	 * 读取FTP服务器将得到的数据插入数据库
	 * 
	 * 
	 * 
	 * 
	 * 
	 */

	@RequestMapping(value = "/getInfo", method = RequestMethod.GET)
	public void insertData1() {
		FTPUtil fu = new FTPUtil();
		String data = fu.readConfigFileForFTP("ysq", "ysq320925", "/FTP下载",
				"172.16.36.184", 2121, "ysq.json");
		ResultInsertInfo resultInsertInfo = JSONObject.parseObject(data,
				ResultInsertInfo.class);
		for (InsertInfo insertInfo : resultInsertInfo.getListInsertInfo()) {
			// System.out.println(insertInfo);
			insertInfoService.insertInfoForFtp(insertInfo);
		}

	}

}
